<template>
	<div>
		<view class="weui-cells weui-cells_after-title ">
			<view class="weui-cell">
				<view class="weui-cell__hd">
					<image :src="'https://tp5.blver.cn'+orderdetail.goods_image" style="margin-right: 5px;vertical-align: middle;width:80px; height: 80px;"></image>
				</view>
				<view class="weui-cell__bd">{{orderdetail.goods_title}}</view>
				<view class="weui-cell__ft">{{orderdetail.selling_price}}</view>
			</view>
		</view>
		
		<div class="line"></div>
		
		<view class="weui-cells weui-cells_after-title">
            <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">配送时间</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" v-model="orderdetail.sendtime" disabled="disabled"/>
                </view>
            </view>
            
            <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">配送信息</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" :value="orderdetail.sendby+'/'+orderdetail.sendbytel" disabled="disabled"/>
                </view>
                <view class="weui-cell__ft">
                    <view class="weui-vcode-btn">{{orderdetail.noname==0?'':'匿名'}}</view>
                </view>
            </view>
            <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">收货地址</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" :value="orderdetail.sendaddress.province+orderdetail.sendaddress.city+orderdetail.sendaddress.area" disabled="disabled"/>
                </view>
            </view>
		</view>
		
		<div class="line"></div>
		
		
		<view class="weui-cells weui-cells_after-title">
			 <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">卡片留言</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" v-model="orderdetail.cardmsg" disabled="disabled"/>
                </view>
            </view>
            <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">特殊要求</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" v-model="orderdetail.otherrequest" disabled="disabled"/>
                </view>
            </view>
		</view>
		
		
		<div class="line"></div>
		
		<view class="weui-cells weui-cells_after-title">
			<view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">订单时间</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" :value="orderdetail.create_at" disabled="disabled"/>
                </view>
            </view>
			<view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">订单金额</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" :value="orderdetail.selling_price*orderdetail.number" disabled="disabled"/>
                     
                </view>
                <view class="weui-cell__ft">
                    <view class="weui-vcode-btn">使用了{{orderdetail.score}}积分</view>
                </view>
            </view>
            <view class="weui-cell weui-cell_input">
                <view class="weui-cell__hd">
                    <view class="weui-label">实付</view>
                </view>
                <view class="weui-cell__bd">
                    <input class="weui-input" :value="orderdetail.pay_price*orderdetail.number" disabled="disabled"/>
                </view>
            </view>
			
		</view>
		
		
		
		<div class="bottom_float_div pf row" style="z-index:100" v-if="orderdetail.status && orderdetail.status==6">

			<div class="collection " style="float:left;width:50%" @click="returns()">

				<div>返回</div>

			</div>

			<div class="buyNow gw1" style="width:50%; float:left" >
				<a style="color:#fff;">
					<div>已退款</div>
				</a>
			</div>
		</div>
		<div class="bottom_float_div pf row" style="z-index:100" v-else-if="orderdetail.status && orderdetail.status==2">

			<div class="collection " style="float:left;width:50%" @click="returns()">

				<div>返回</div>

			</div>

			<div class="buyNow gw1" style="width:50%; float:left" @click="refund()">
				<a style="color:#fff;">
					<div>申请退款</div>
				</a>
			</div>
		</div>
		<div class="bottom_float_div pf row" style="z-index:100" v-else-if="orderdetail.status && orderdetail.status==5">

			<div class="collection " style="float:left;width:50%" @click="returns()">

				<div>返回</div>

			</div>

			<div class="buyNow gw1" style="width:50%; float:left" >
				<a style="color:#fff;">
					<div>已完成</div>
				</a>
			</div>
		</div>
		
		<div class="bottom_float_div pf row" style="z-index:100" v-else-if="orderdetail.status && orderdetail.status==7">

			<div class="collection " style="float:left;width:50%" @click="returns()">

				<div>返回</div>

			</div>

			<div class="buyNow gw1" style="width:50%; float:left"  @click="returnscancel()">
				<a style="color:#fff;">
					<div>取消退款</div>
				</a>
			</div>
		</div>
		
		
	</div>
</template>

<script>
	import { requests } from "../../../static/js/network"
	export default{
		data(){
			return{
				orderdetail:{}
			}
		},
		methods:{
			returns(){
				wx.navigateBack({
					delta:1
				})
			},
			returnscancel(){
				let self = this
				requests({
					url: 'https://tp5.blver.cn/api/wechat/cancelRefund',
					method: 'POST',
					header: {
						'content-type': 'application/json',
						'content-type': 'application/x-www-form-urlencoded' // 默认值
					},
					data: {
						orderno:self.$root.$mp.query.id,
						session3rd: wx.getStorageSync('userinfo').session3rd
					},
					success: function(res) {
						
					
						if(res.data.status=='error'){
							wx.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						})
						}else{
							wx.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						})
							wx.redirectTo({
							  url: "/pages/orderlist/main"
							})
						}
						console.log(res)

					}
				})
			},
			refund(){
				let self = this
				requests({
					url: 'https://tp5.blver.cn/api/wechat/applyRefund',
					method: 'POST',
					header: {
						'content-type': 'application/json',
						'content-type': 'application/x-www-form-urlencoded' // 默认值
					},
					data: {
						orderno:self.$root.$mp.query.id,
						session3rd: wx.getStorageSync('userinfo').session3rd
					},
					success: function(res) {
						
						
						if(res.data.status=='error'){
							wx.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						})
						}else{
							wx.showToast({
							title: res.data.msg,
							icon: 'none',
							duration: 2000
						})
							wx.redirectTo({
							  url: "/pages/orderlist/main"
							})
						}
						console.log(res)

					}
				})
			}
		},
		onLoad(){
			let self = this
				requests({
					url: 'https://tp5.blver.cn/api/wechat/getOrder',
					method: 'POST',
					header: {
						'content-type': 'application/json',
						'content-type': 'application/x-www-form-urlencoded' // 默认值
					},
					data: {
						orderno:self.$root.$mp.query.id,
						session3rd: wx.getStorageSync('userinfo').session3rd
					},
					success: function(res) {
						
						self.orderdetail=res.data.data
						console.log(res)
						//self.content=self.classlist[0].goods_content.replace(/"\/static/g, '"https://tp5.blver.cn/static').replace(/"\/static/g, '"https://tp5.blver.cn/static').replace(/\<img/gi, '<img style="max-width:100%;height:auto" ')
					}
				})
		}
	}
</script>

<style>
.flexs{display: flex; font-size: 28rpx;}
.tit{width: 20%; padding: 5rpx 10rpx; text-align: justify; text-align-last:justify;}
.content{width: 85%;padding: 5rpx 10rpx;}
.line{height: 10rpx; background: #ccc;}
.noname{color: deeppink;}


.pf{position:fixed}
.bottom_float_div{width:100%;text-align:center;bottom:0;background:#fff;left:0;right:0;max-width:620px;margin:0 auto}

.row{flex-direction:row;display:flex}
.pf{position:fixed}
.collection{width:16%;color:#999;height:35px;line-height:35px;border-top:1px #cacaca solid;font-size: 30rpx;}
.buyNow{width:42%;width:100%;line-height:35px;background-color:#f44;color:#fff;font-size: 30rpx}
</style>